<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="com.blockchain.console.servlets.financial.bzc.XlbYc"%>
<%@page import="com.blockchain.console.servlets.financial.bzc.XlbBd"%>
<%@page import="com.blockchain.common.enums.WithdrawStatus"%>
<%@page import="com.blockchain.console.servlets.financial.bzc.ZbshPl"%>
<%@page import="java.math.BigDecimal"%>
<%@page import="com.blockchain.console.servlets.financial.bzc.ExportBzc"%>
<%@page import="com.blockchain.console.servlets.financial.bzc.ZbZcSh"%>
<%@page import="com.blockchain.console.servlets.financial.bzc.ZbSh"%>
<%@page import="com.blockchain.common.enums.XlbZcStatus"%>
<%@page import="com.blockchain.console.servlets.financial.bzc.BzcList"%>
<%@page import="com.blockchain.console.service.trading.entity.XlbEntity"%>
<%@page import="com.blockchain.console.service.financial.entity.BEntity"%>
<%@page import="com.blockchain.console.servlets.financial.cz.CzRgqr"%>
<%@page import="com.blockchain.console.servlets.financial.cz.ExportCzgl"%>
<%@page import="com.blockchain.common.enums.IsPass"%>
<%@page import="com.blockchain.common.enums.ChargeType"%>
<%@page import="com.blockchain.console.servlets.financial.AbstractFinancialServlet"%>
<%@page import="com.blockchain.console.servlets.financial.cz.CzglList"%>
<%@page import="com.blockchain.console.service.financial.entity.CzglRecord"%>
<%@page import="com.blockchain.common.enums.ChargeStatus"%>
<%@page import="java.text.DecimalFormat"%>

<html>
<head>
<%@include file="/WEB-INF/include/meta.jsp"%>
<%@include file="/WEB-INF/include/style.jsp"%>
</head>
<%
		CURRENT_CATEGORY = "CWGL";
		CURRENT_SUB_CATEGORY = "XLBZC";
		PagingResult<BEntity> result = (PagingResult<BEntity>) request.getAttribute("result");
		XlbEntity [] xlbs=(XlbEntity[])request.getAttribute("xlb");
		String zczt=request.getParameter("zczt");
		BigDecimal totalAmount=new BigDecimal(0);//提币金额
		BigDecimal totalFee=new BigDecimal(0);//提币手续费
%>
<body>
	<%@include file="/WEB-INF/include/header.jsp"%>
	<div class="w_main">
		<div class="main clearfix">
			<div class="wrap">
				<div class="r_main">
					<div class="home_main">
						<form action="<%controller.getURI(request, BzcList.class);%>" method="post" name="form1" id="searchForm">
							<input type="hidden" name="zczt" value="<%=zczt%>" />
							<div class="box box1 mb15">
								<div class="atil">
									<h3>虚拟币转出</h3>
								</div>
							</div>
							<div class="box box1 mb15">
								<div class="con">
									<div class="admin_input admin_pb">
             							<div class="table top3">
											<p>
												<span>用户ID：</span>
												<input type="text" name="userid" value="<%StringHelper.filterHTML(out, request.getParameter("userid")); %>" class="yhgl_input" />
											</p>
											<p>
												<span>用户名：</span>
												<input type="text" name="yhm" value="<%StringHelper.filterHTML(out, request.getParameter("yhm")); %>" class="yhgl_input" />
											</p>
											<P>
												<span>时间：</span>
												<input type="text" name="s" id="datepicker1" readonly="readonly" class="yhgl_input date" />至
												<input type="text" name="e" id="datepicker2" readonly="readonly" class="yhgl_input date" />
											</P>
										<P>
												<span>币种：</span>
												<select name="bid" class="yhgl_sel" >
														<option>请选择</option>
														<%if(xlbs!=null){for (XlbEntity s: xlbs) {%>
														<option value="<%=s.id%>" <%if (s.id==IntegerParser.parse(request.getParameter("bid"))) {%> selected="selected" <%}%>><%StringHelper.filterHTML(out,s.zwm);%>（<%StringHelper.filterHTML(out,s.ywjc);%>）</option>
														<%}}%>
												</select>
											</P>
											
											
<%-- 											<P>
												<span>状态：</span>
												<select name="zt" class="yhgl_sel" >
														<option>请选择</option>
														<%
															for (IsPass is : IsPass.values()) {
														%>
														<option value="<%=is.name()%>" <%if (is.name().equals(request.getParameter("zt"))){%> selected="selected" <%} %>><%=is.getName()%></option>
														<%
															}
														%>
												</select>
											</P>
 --%>												<div class="mt10">   
												<input name="search" type="submit" class="btn2 mr10" value="搜索" />
											<%if (blockchainSession.isAccessableResource(ExportBzc.class)) {%>
											<a href="javascript:void(0)" onclick="showExport()" class="btn3 mr10"><span class="ico"></span>导出</a>
											<%}%>
											</div>
											<div class="clear"></div>
								</div>
								</div>
								</div>
							</div>
							<div class="newsbox">
				<div class="til clearfix">
				<div  class="Menubox">
					<ul>
						<li id="one1" <%if(StringHelper.isEmpty(zczt)){ %>class="hover"<%} %>><a href="<%=controller.getURI(request, BzcList.class)%>">审核中</a></li>
						<li id="one2" <%if(XlbZcStatus.SHTG.name().equals(zczt)){ %>class="hover"<%} %>><a href="<%=controller.getURI(request, BzcList.class)%>?zczt=<%=XlbZcStatus.SHTG %>">审核通过</a></li>
						<li id="one3" <%if(XlbZcStatus.ZCCG.name().equals(zczt)){ %>class="hover"<%} %>><a href="<%=controller.getURI(request, BzcList.class)%>?zczt=<%=XlbZcStatus.ZCCG %>">转出成功</a></li>
						<li id="one3" <%if(XlbZcStatus.SHSB.name().equals(zczt)){ %>class="hover"<%} %>><a href="<%=controller.getURI(request, BzcList.class)%>?zczt=<%=XlbZcStatus.SHSB %>">审核失败</a></li>
						<li id="one5" <%if(XlbZcStatus.ZCSB.name().equals(zczt)){ %>class="hover"<%} %>><a href="<%=controller.getURI(request, BzcList.class)%>?zczt=<%=XlbZcStatus.ZCSB %>">转出失败</a></li>
					</ul>
				</div>
				<div class="clear"></div>
					</div>
					</div>
						<table width="100%" border="0" cellspacing="0" cellpadding="0" class="yhgl_table tc">
								<tr class="hsbg">
									<td><input type="checkbox" class="checkAll" /></td>
									<td>序号</td>
									<td>用户ID</td>
									<td>用户名</td>
									<td>币种/简称</td>
									<td>转出数量</td>
									<td>手续费</td>
									<td>实际到账</td>
									<td>转出地址</td>
									<td>
								 <%if(StringHelper.isEmpty(zczt)){ %>
									申请时间
								<%}if(XlbZcStatus.SHTG.name().equals(zczt)||XlbZcStatus.SHSB.name().equals(zczt)){%>
									申请时间/审核时间	
								<%}if(XlbZcStatus.ZCCG.name().equals(zczt)){%>
									申请时间/转出时间
								<%}if(XlbZcStatus.ZCSB.name().equals(zczt)){%>	
									申请时间/转出审核时间
								<%}%>
									</td>
									<!-- <td>状态</td> -->
									<td>操作</td>
								</tr>
								<%
								BEntity[] items = result.getItems();
										if (items != null) {
											int i=1;
											for (BEntity b : items) {
												if (b == null) {
													continue;
												}
												totalAmount=totalAmount.add(b.zcsl);
												totalFee=totalFee.add(b.sxf);		
								%>
								<tr class="dhsbg">
									<td><input type="checkbox" class="checkId" name="id" value="<%=b.id%>" /></td>
									<td><%=b.id%></td>
									<td><%=b.userid%></td>
									<td><%StringHelper.filterHTML(out, b.username);%></td>
									<td><%StringHelper.filterHTML(out, b.b_zwm);%>/<%StringHelper.filterHTML(out, b.b_ywm);%></td>
									<td><%=Formater.formatAmount_6(b.zcsl.add(b.sxf))%></td>
									<td><%=Formater.formatAmount_6(b.sxf)%></td>
									<td><%=Formater.formatAmount_6(b.zcsl)%></td>
									<td><%StringHelper.filterHTML(out, b.zcdz);%></td>
									<td>
								<%if(StringHelper.isEmpty(zczt)){ %>
								<%=DateTimeParser.format(b.sj,"yyyy-MM-dd HH:mm")%>
								<%}if(XlbZcStatus.SHTG.name().equals(zczt)||XlbZcStatus.SHSB.name().equals(zczt)){%>
									<%=DateTimeParser.format(b.sj,"yyyy-MM-dd HH:mm")%>/<%=DateTimeParser.format(b.shsj,"yyyy-MM-dd HH:mm")%>
								<%}if(XlbZcStatus.ZCCG.name().equals(zczt)){%>
								<%=DateTimeParser.format(b.sj,"yyyy-MM-dd HH:mm")%>/<%=DateTimeParser.format(b.zcsj,"yyyy-MM-dd HH:mm")%>
								<%}if(XlbZcStatus.ZCSB.name().equals(zczt)){%>	
									<%=DateTimeParser.format(b.sj,"yyyy-MM-dd HH:mm")%>/<%=DateTimeParser.format(b.zcsj,"yyyy-MM-dd HH:mm")%>
								<%}%>
									
									</td>
									<%-- <td><%=b.zt.getName()%></td> --%>
									<td>
									<%if (blockchainSession.isAccessableResource(ZbSh.class) && XlbZcStatus.WSH.equals(b.zczt)) {%>
              						<span class="blue"><a href="<%=controller.getURI(request,ZbSh.class)%>?id=<%=b.id%>" class="mr10">审核</a></span>
              						<%}%>
              						<%if (blockchainSession.isAccessableResource(ZbZcSh.class) && XlbZcStatus.SHTG.equals(b.zczt)) {%>
              						<span class="blue"><a href="<%=controller.getURI(request,ZbZcSh.class)%>?id=<%=b.id%>" class="mr10">转出审核</a></span>
              						<%}%>
              						<%if (blockchainSession.isAccessableResource(XlbBd.class)&& XlbZcStatus.ZCCG.equals(b.zczt)&&b.sfbd==IsPass.F) {%>
									<span class="blue"><a   onclick="load('<%=controller.getURI(request, XlbBd.class)%>?id=<%=b.id%>')" href="javascript:void(0)"   class="mr10">补单</a></span>		
									<%}%>
									<%if(blockchainSession.isAccessableResource(XlbYc.class)&&StringHelper.isEmpty(b.sfyc)&& XlbZcStatus.ZCCG.equals(b.zczt)&&b.id>1479) {%>
									<span class="red"><a onclick="hx('<%=b.id%>')"  href="javascript:void" class="red">异常</a></span>
									<%}else if(StringHelper.isEmpty(b.sfyc)&& XlbZcStatus.ZCCG.equals(b.zczt)&&b.id>1479){%>
                          			<span class="red">异常</span>
									<%}%>
              					</td>
								</tr>
								<%}}%>
								<tr class="dhsbg">
											<td colspan="14" align="left">
											<span style="padding-top: 5px">总计：提币金额 <span style="color: red;"><%=Formater.formatAmount(totalAmount) %></span>,
											手续费<span style="color: red;"><%=Formater.formatAmount(totalFee) %></span>,
											共<span style="color: red;"><%=items!=null?items.length:0 %></span>笔</span>
											</td>
								</tr>
							</table>
											<%if (blockchainSession.isAccessableResource(ZbshPl.class)&& (XlbZcStatus.WSH.name().equals(zczt)||StringHelper.isEmpty(zczt))) {%>
											<input type="button" class="btn3 mr10" value="批量审核通过" onclick="checkAll('<%=XlbZcStatus.SHTG.name()%>','<%=controller.getURI(request, ZbshPl.class)%>')" /> 
											<%}%>
											<%if (blockchainSession.isAccessableResource(ZbshPl.class)&& (XlbZcStatus.WSH.name().equals(zczt)||StringHelper.isEmpty(zczt))) {%>
											<input type="button" class="btn3 mr10" onclick="checkAll('<%=XlbZcStatus.SHSB.name()%>','<%=controller.getURI(request, ZbshPl.class)%>')" value="批量审核不通过" />
											<%}%>
							<%
							AbstractFinancialServlet.rendPagingResult(out, result);
							%>
							<div class="box2 clearfix"></div>
						</form>
					</div>
				</div>
			</div>
			<%@include file="/WEB-INF/include/left.jsp"%>
		</div>
	</div>
		<div id="reasonDiv" style="display: none;">
		<div class="popup_bg"></div>
		<div class="popup add_information"
			style="width: 450px; margin: -70px 0 0 -225px; height: 200px; z-index: 99999; position: fixed; left: 50%; top: 50%; _position: absolute; _top: expression(200 +((   e =   document.documentElement.scrollTop)?e:document.body.scrollTop)+'px'); z-index: 100000;">
			<div class="til clearfix">
				<h2>批量审核不通过</h2>
				<div class="close">
					<a href="javascript:void(0)" class="close">关闭</a>
				</div>
			</div>
			<div class="con">
				 <form action="<%=controller.getURI(request, ZbshPl.class)%>" method="post">
					<input type="hidden" name="status" value="<%=XlbZcStatus.SHSB.name()%>" /> 
					<input type="hidden" name="ids" id="ids" /> 
					<table>
						<tr>
							<td valign="top"><span>请填写不通过的原因:</span></td>
							<td><textarea rows="4" cols="40" name="check_reason"></textarea></td>
						</tr>
						<tr align="center">
							<td colspan="2"><button type="submit" class="btn3">确认</button>
								<button type="button" class="btn5 close">取消</button></td>
						</tr>
					</table>
				</form>
			</div>
		</div>
	</div>
	
	
			<div id="hx" style="display: none">
					<div class="popup_bg"></div>
						<div class="w440 thickbox thickpos" style="margin:-80px 0 0 -220px;" id="showDiv">
					      <div class="info clearfix">
					      	  <div class="clear"></div>
						      <form action="<%=controller.getURI(request, XlbYc.class)%>" method="post"  class="form1"  onsubmit="return onSubmit()" >
						      <input type="hidden" name="id" id="id">
								<div class="clear"></div>
						        <div class="clearfix" style="margin-left: 40px;">
								<div class="table">
										
												<span>描述:</span>
												<input type="text"  name="bz" style="width: 200px;"
												class="text yhgl_ser required"/>
												<div class="clear"></div>
												<p errortip style="margin-left: 30px;" style="display: none"></p>
								</div>
								<div class="clear"></div>
								</div>		
									<div class="tc w220 pt20"">
										<input type="submit" style="cursor: pointer;" value="提交"  class="btn3 mr30 sumbitForme"  fromname="form1"/> 
										<input type="button"  name="button2" onclick="$('#hx').hide()" value="取消" class="btn5" />
									</div>
								</form>
					      </div>
						</div>
					</div>	
	<%@include file="/WEB-INF/include/footer.jsp"%>
	<%@include file="/WEB-INF/include/script.jsp"%>
	<%@include file="/WEB-INF/include/datepicker.jsp"%>
	<script type="text/javascript"src="<%=controller.getStaticPath(request)%>/js/validation.js"></script>
	<script type="text/javascript">
	$(function() {
		$("#datepicker1").datepicker({inline: true});
	    $('#datepicker1').datepicker('option', {dateFormat:'yy-mm-dd'});
	    $("#datepicker2").datepicker({inline: true});
	    $('#datepicker2').datepicker('option', {dateFormat:'yy-mm-dd'});
	    $("#datepicker1").datepicker("setDate", "<%StringHelper.filterHTML(out, request.getParameter("s"));%>");
	    $("#datepicker2").datepicker("setDate", "<%StringHelper.filterHTML(out, request.getParameter("e"));%>");
	});
	
	function showExport()
	{
		document.getElementById("searchForm").action ="<%=controller.getURI(request, ExportBzc.class)%>";
		$("#searchForm").submit();
		document.getElementById("searchForm").action ="<%=controller.getURI(request, BzcList.class)%>";
	}
	
	$(".checkAll").click(function() {
		var checked = $(".checkAll").attr("checked");
		if (checked == 'checked') {
			$(".checkId").attr("checked", true);
		} else {
			$(".checkId").attr("checked", false);
		}
	});

	$(".checkId").click(function() {
		var checkBoxs = $(".checkId");
		var isCheckedAll = true;
		for ( var i = 0; i <= checkBoxs.length - 1; i++) {
			if ($(checkBoxs[i]).attr("checked") != "checked") {
				isCheckedAll = false;
			}
		}
		if (isCheckedAll) {
			$(".checkAll").attr("checked", true);
		} else {
			$(".checkAll").attr("checked", false);
		}
	});
	
	function checkAll(status,url) {
		$("#reasonDiv").hide();
		var ids = "";
		var ckeds = $(".checkId:checked");
		if (ckeds == null || ckeds.length <= 0) {
			alert("请选择提现记录!");
			return;
		}
		if (status == 'SHTG' && !window.confirm("是否执行'批量审核通过'")) {
			return;
		} else if (status == 'SHSB' && !window.confirm("是否执行'批量审核不通过'")) {
			return;
		}
		for ( var i = 0; i < ckeds.length; i++) {
			var val = $(ckeds[i]).val();
			if (i == 0) {
				ids += val;
			} else {
				ids += "," + val;
			}
		}
		if (status == 'SHTG') {
			location.href = url + "?status="+ status + "&ids=" + ids;
		} else {
			$("#ids").attr("value", ids);
			$("#reasonDiv").show();
		}
	}
	
	$(".close").click(function() {
		$("#reasonDiv").hide();
	});
	
	function load(url)
	{
		if (!window.confirm("你确定用户没有收到此笔转币并且为用户补单吗？")) {
			return;
		}
		location.href=url;
	}
	
	function hx(id){
		$("#hx").show();
		$("#id").val(id);
	}
	</script>
</body>
</html>
